package com.hunzi.service.impl;

import com.hunzi.domain.User;
import com.hunzi.mapper.UserMapper;
import com.hunzi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired(required = false)
    private UserMapper userMapper ;

    @Override
    public int deleteByPrimaryKey(Integer uid) {
        return userMapper.deleteByPrimaryKey ( uid );
    }

    @Override
    public int insert(User user) {
        return userMapper.insert ( user );
    }

    @Override
    public User selectByPrimaryKey(Integer uid) {
        User user = userMapper.selectByPrimaryKey ( uid );
        return user;
    }

    @Override
    public List<User> selectAll() {
        List<User> users = userMapper.selectAll ();
        return users;
    }

    @Override
    public int updateByPrimaryKey(User uid) {
        return userMapper.updateByPrimaryKey ( uid );
    }

    @Override
    public User loginUser(String username, String password) {

        return userMapper.loginUser ( username , password );
    }

    @Override
    public List<User> selectByWhere(User condition) {
        List<User> users = userMapper.selectByWhere ( condition );
        return   users;
    }

    @Override
    public void deleteByIds(int[] ids) {
        userMapper.deleteByIds ( ids );
    }


}
